package com.suke.czx.modules.wxadmin.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.suke.czx.common.utils.PageUtils;
import com.suke.czx.common.utils.Query;
import com.suke.czx.common.utils.R;
import com.suke.czx.modules.wxadmin.entity.DkUserAddressEntity;
import com.suke.czx.modules.wxadmin.service.DkUserAddressService;




/**
 * 
 * 
 * @author zdw
 * @email zdw@163.com
 * @date 2019-03-16 20:54:16
 */
@RestController
@RequestMapping("/wxadmin/dkuseraddress")
public class DkUserAddressController {
    @Autowired
    private DkUserAddressService dkUserAddressService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("wxadmin:dkuseraddress:list")
    public R list(@RequestParam Map<String, Object> params){
        //查询列表数据
        Query query = new Query(params);

        List<DkUserAddressEntity> dkUserAddressList = dkUserAddressService.queryList(query);
        int total = dkUserAddressService.queryTotal(query);

        PageUtils pageUtil = new PageUtils(dkUserAddressList, total, query.getLimit(), query.getPage());

        return R.ok().put("page", pageUtil);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{openid}")
    @RequiresPermissions("wxadmin:dkuseraddress:info")
    public R info(@PathVariable("openid") String openid){
			DkUserAddressEntity dkUserAddress = dkUserAddressService.queryObject(openid);

        return R.ok().put("dkUserAddress", dkUserAddress);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("wxadmin:dkuseraddress:save")
    public R save(@RequestBody DkUserAddressEntity dkUserAddress){
			dkUserAddressService.save(dkUserAddress);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("wxadmin:dkuseraddress:update")
    public R update(@RequestBody DkUserAddressEntity dkUserAddress){
			dkUserAddressService.update(dkUserAddress);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("wxadmin:dkuseraddress:delete")
    public R delete(@RequestBody String[] openids){
			dkUserAddressService.deleteBatch(openids);

        return R.ok();
    }
	
}
